﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;
namespace chatblog.login
{
    public partial class userphoto : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser.dealcookie();
                dealrequest();
                bind1();
                //bind2();
                //bind3();
            }
        }
        /// <summary>
        /// 绑定
        /// </summary>
        private void bind1()
        {
            //cbuser u = cbuser.Find(" cbuserid = '" + AliApi.appUserId + "'", "RECID");
            //TextBox1.Text = u.cbusernickname.ToString();
        }
        private void dealrequest()
        {
            if (AliApi.appUserId == "")
            {
                Response.Redirect("login.aspx?redirecturl=" + "userphoto.aspx");
            }
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload_fj.FileName.Substring(FileUpload_fj.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload_fj.HasFile)
            {
                FileUpload_fj.SaveAs(strFilePth);
                cbuser u = cbuser.Find(" cbuserid = '" + AliApi.appUserId + "'", "RECID");
                u.cbimgpath.Value = linkpth;
                u.Modify();
                MessageBox.Show(this.Page, "上传成功");
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            cbuser u = cbuser.Find(" cbuserid = '" + AliApi.appUserId + "'", "RECID");
            u.cbimgpath.Value = "";
            u.Modify();
        }
    }
}
